<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>分类列表</title>
<link rel="stylesheet" href="/static/admin/css/page_navigation.css" type="text/css">
</head>
<body>
<?php include APP_ADMIN_VIEW . 'include/head.php';?>
<!-- Table goes in the document BODY -->
<table class="data_list">
<tr>
<td colspan="2">
<a href="/<?php echo APP_ADMIN_URI; ?>/category/create">新建分类</a>
</td>
<td colspan="4">
<div class="pagination">
<ul>
   <?php echo $page_navigation; ?>
</ul>
</div>
    </td>
    <td colspan="3">
        <form accept="/<?php echo APP_ADMIN_URI; ?>/category/list" method="GET">
            <input type="text" name="k" value="<?php echo $keyword; ?>"/>
            <input type="submit" value="搜索"/>
        </form>
    </td>
</tr>
<tr>
    <th>编号</th><th>分类名称</th><th>上级分类</th><th>路径</th><th>文章数</th><th>更新</th><th>状态</th><th>编辑</th>
</tr>
<?php if ($category_array): ?>
<?php foreach ($category_array as $category_data): ?>
<tr>
    <td width="5%"><?php echo $category_data['id']; ?></td>
    <td width="15%">
        <a href="/<?php echo APP_ADMIN_URI; ?>/category/create?hash=<?php echo isset($category_data['hash']) ? $category_data['hash'] : ''; ?>" target="_blank">
        <?php echo isset($category_data['category_name']) ? $category_data['category_name'] : ''; ?>
        </a>

        </td>
    <td width="15%">
      <a href="/<?php echo APP_ADMIN_URI; ?>/category/list?cid=<?php echo isset($category_data['parent_id']) ? $category_data['parent_id'] : '0'; ?>">
        <?php echo isset($category_data['parent_category_name']) ? $category_data['parent_category_name'] : ''; ?>
      </a>
        </td>
    <td width="20%"><?php echo isset($category_data['category_path']) ? $category_data['category_path'] : ''; ?></td>
    <td width="5%"><?php echo isset($category_data['post_count']) ? $category_data['post_count'] : ''; ?></td>
    <td width="5%"><?php echo isset($category_data['is_build']) ? $category_data['is_build'] : ''; ?></td>
    <td width="5%"><?php echo isset($category_data['status']) ? $category_data['status'] : ''; ?></td>
    <td width="15%">
        <a href="/<?php echo APP_ADMIN_URI; ?>/category/create?hash=<?php echo isset($category_data['hash']) ? $category_data['hash'] : ''; ?>">编辑</a>&nbsp;|&nbsp;
        <a href="javascript:deletePost('<?php echo isset($category_data['hash']) ? $category_data['hash'] : ''; ?>')">删除</a>
        <a href="javascript:buildCategory('<?php echo isset($category_data['hash']) ? $category_data['hash'] : ''; ?>')">更新</a>
        <a href="/<?php echo APP_ADMIN_URI; ?>/category/preview?hash=<?php echo isset($category_data['hash']) ? $category_data['hash'] : ''; ?>" target='_blank'>预览</a>
        </td>
</tr>
<?php endforeach?>
<?php else: ?>
<tr>
    <td colspan="9">暂无数据</td>
</tr>
<?php endif?>
<tr>
    <td  colspan="9">
        <div class="pagination">
<ul>
<?php echo $page_navigation; ?>
</ul>
</div>
    </td>
</tr>
</table>

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    function deletePost(hash)
    {
        var msg = "您真的确定要删除吗？";
        if (confirm(msg)==true){
          htmlobj=$.ajax({url:"/<?php echo APP_ADMIN_URI; ?>/category/delete?hash="+hash,async:false});
          if (htmlobj.responseText=="1") {
               //$("#tr"+num).hide();
               alert('删除成功');
               location.reload();
          }
        }

    }
    function buildCategory(hash)
    {
          htmlobj=$.ajax({url:"/admin/build/category?hash="+hash,async:false});
          if (htmlobj.responseText=="1") {
               location.reload();
          }
    }
</script>
<?php include APP_ADMIN_VIEW . 'include/foot.php';?>
</body>
</html>